package org.wlgzs.office_exam_student.service;

import java.sql.SQLException;
import java.sql.Timestamp;

import org.wlgzs.office_exam_student.dao.BaseDao;
import org.wlgzs.office_exam_student.entity.Exam;
import org.wlgzs.office_exam_student.entity.User;

/**
*@author song(mejeesong@qq.com)
*2018年2月3日
*
*/
public class ExamService extends BaseDao<Exam>{
	public Exam getCurrExam(User user) {
		if(user == null) {
			return null;
		}
		int classId = user.getClassesId();
		return getCurrExam(classId);
	}
	public Exam getCurrExam(int classId) {
		String sql = "select * from  tb_exam  where  classes_id = ? and now() between start_time and end_time";
		return exec( qr -> {
			try {
				return qr.query(sql, BEAN_HANDLER, classId);
			} catch (SQLException e) {
				e.printStackTrace();
				return null;
			}
		});
	}
}
